﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TeamDraft;

namespace DraftTesting
{
    class Program
    {
        static void Main(string[] args)
        {
            TestEventArg0();

            TestEventArgTeamRound();

            DraftEvent currentevent;

            currentevent = TestEventArgType();

            currentevent.Type = DraftType.StarTournament;

            TeamDraft.TeamDraft currentdraft = new TeamDraft.TeamDraft(currentevent);

            DisplayTeamDraft(currentdraft);

            currentdraft.Teams[0] = "Wonder Ones";
            currentdraft.Teams[1] = "Terrible Twos";
            currentdraft.Teams[2] = "Toothy Threes";
            currentdraft.Teams[3] = "Formidable Fours";
            currentdraft.Teams[4] = "Golden Rings";
            currentdraft.Teams[5] = "Seal Team Six";
            currentdraft.Teams[6] = "Lucky Seven";
            currentdraft.Teams[7] = "Crazy Eight";

            DisplayTeamDraft(currentdraft);

            for (int i = 1; i <= 40; i++)
            {
                int compute;
                compute = currentdraft.CurrentRound * 1000 + currentdraft.Pick();
                currentdraft.SelectPick(compute);
                Console.WriteLine("Last Pick: {0}; Current Team: {1}; Current Round: {2}", currentdraft.LastPick.ToString(), currentdraft.CurrentTeam.ToString(), currentdraft.CurrentRound.ToString());
                Console.WriteLine("PickedID: {0}", compute);
            }

            DisplayTeamDraft(currentdraft);

            Console.WriteLine("PickedID: 2010 is {0}", currentdraft.Pick(2010));
            Console.WriteLine("PickedID: 4028 is {0}", currentdraft.Pick(4028));
            Console.WriteLine("PickedID: 10000 is {0}", currentdraft.Pick(10000));
            Console.WriteLine("\n");

            Pick pickcheck = currentdraft.Pick(7,3);
            Console.WriteLine("Team 7, Round 3, is Pickindex:{0} and Pickedid:{1}", pickcheck.PickIndex, pickcheck.PickedID);
            pickcheck = currentdraft.Pick(7, 4);
            Console.WriteLine("Team 7, Round 4, is Pickindex:{0} and Pickedid:{1}", pickcheck.PickIndex, pickcheck.PickedID);
            pickcheck = currentdraft.Pick(27, 4);
            Console.WriteLine("Team 27, Round 4, is Pickindex:{0} and Pickedid:{1}", pickcheck.PickIndex, pickcheck.PickedID);
            pickcheck = currentdraft.Pick(7, 34);
            Console.WriteLine("Team 7, Round 34, is Pickindex:{0} and Pickedid:{1}", pickcheck.PickIndex, pickcheck.PickedID);
            pickcheck = currentdraft.Pick(2, 4);
            Console.WriteLine("Team 2, Round 4, is Pickindex:{0} and Pickedid:{1}", pickcheck.PickIndex, pickcheck.PickedID);

            Console.ReadKey();

        }

        static private void DisplayDraftEvent(DraftEvent draft)
        {
            Console.WriteLine("Title: \t \t \t {0}", draft.Title);
            Console.WriteLine("SubTitle: \t \t {0}", draft.Subtitle);
            Console.WriteLine("Location: \t \t {0}", draft.Location);
            Console.WriteLine("Date: \t \t \t {0}", draft.Date.ToShortDateString());
            Console.WriteLine("Team Count: \t \t {0}", draft.TeamCount);
            Console.WriteLine("Round Count: \t \t {0}", draft.RoundCount);
            Console.WriteLine("Style: \t \t \t {0}", draft.Style);
            Console.WriteLine("\n");
        }

        static private void TestEventArg0()
        {
            DraftEvent currentevent = new DraftEvent();

            DisplayDraftEvent(currentevent);
            
            currentevent.Title = "Mikes Test Program";
            currentevent.Subtitle = "For Testing Draft Library No args";
            currentevent.Location = "Portland, Maine";
            currentevent.Style = DraftStyle.Snake;
            currentevent.Date = DateTime.MinValue;
            currentevent.RoundCount = 20;
            currentevent.TeamCount = 10;

            DisplayDraftEvent(currentevent);
        }

        static private void TestEventArgTeamRound()
        {
            DraftEvent currentevent = new DraftEvent(12, 17);

            DisplayDraftEvent(currentevent);

            currentevent.Title = "Mikes Test Program";
            currentevent.Subtitle = "For Testing Draft Library team and round args";
            currentevent.Location = "Portland, Ore";
            currentevent.Style = DraftStyle.Other;
            currentevent.Date = DateTime.Today.AddDays(20);

            DisplayDraftEvent(currentevent);
        }

        static private DraftEvent TestEventArgType()
        {
            DraftEvent currentevent = new DraftEvent(DraftType.StarTournament);

            DisplayDraftEvent(currentevent);

            currentevent.Subtitle = "For Testing Draft Library draft type args";
            currentevent.Location = "Los Angeles, CA";
            currentevent.Date = DateTime.Today.AddDays(30);

            DisplayDraftEvent(currentevent);

            currentevent.Title = "Mikes Test Program";
            
            return currentevent;
        }

        static private void DisplayTeamDraft(TeamDraft.TeamDraft draft)
        {
            Console.WriteLine("Event: \t \t \t {0}", draft.Draft);
            Console.WriteLine("CurrentTeam: \t \t {0}", draft.CurrentTeam);
            Console.WriteLine("CurrentRound: \t \t {0}", draft.CurrentRound);
            Console.WriteLine("Last Pick: \t \t {0}", draft.LastPick);
            Console.WriteLine("CurrentPick: \t \t {0}", draft.Pick());
            Console.WriteLine("Teams --");
            foreach (string s in draft.Teams)
            {
                Console.Write("{0} \t",s);
            }
            Console.WriteLine("\n");
            Console.WriteLine("Picks -- ");
            foreach (Pick p in draft.Picks)
            {
                Console.Write("DraftPickId: {0} PickedID: {1}\t", p.PickIndex, p.PickedID);
            }
            Console.WriteLine("\n");
        }

  
    }
}
